package edu.hunau.cxb17.action;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Controller     //表示该类作为一个控制器的类
public class UserManagerAction {

    @RequestMapping("/showall") //绑定一个请求
    public ModelAndView showAll(){
        //封装数据
        List<String> datas = new ArrayList<>();
        Collections.addAll(datas,"haoren","lucy","batman");
        //实例化一个ModelAndView对象封装数据
        ModelAndView mv = new ModelAndView();
        //绑定数据
        mv.addObject("datas",datas);
        //绑定试图资源
        mv.setViewName("/WEB-INF/jsp/list.jsp");

        return mv;

    }

}
